import excel "missing drug names_extract_30APR2020.xls", sheet("Sheet1") clear

* drug_name correction st_reg_id sa_num arm intv_num sa_intv_desc
drop if A=="" | A=="."
rename A drug_name_correction
rename B st_reg_id 
rename C sa_num
rename D arm_old
rename E intv_num
rename F intv_desc2
sort st_reg_id sa_num intv_num
save dc1, replace


use "2020-05-07_iddo_lsr_covid-19_sr.dta", clear


keep if pickone_int_level_record == 1

tab sa_intv_target
keep if inlist(sa_intv_target,1,5)==1

*********number of arms with PI and ATMs*****************
egen arm1 = group(st_reg_id sa_num)
su arm1
drop arm1
*********************************************************

gen study_type = "RCT" if st_design==1
replace study_type = "Cohort / non-randomised" if inlist(st_design,3,4)==1
replace study_type="Case series" if st_design==6
replace study_type="Case-control" if st_design==7
replace study_type ="Quasi-randomised" if st_design==2
keep if study_type!=""

*********number of arms with PI and ATMs************
egen arm1 = group(st_reg_id sa_num) if study_type=="RCT"
su arm1
drop arm1

egen arm1 = group(st_reg_id sa_num) 
su arm1
drop arm1

***********************************************************

***********************************************************
egen study=group(st_reg_id)
egen arm= group(study sa_num)


local i=1
foreach var in sa_intv_drug_av_ns sa_intv_drug_av_bs sa_intv_drug_av_ar sa_intv_drug_av_oth sa_intv_drug_am sa_intv_drug_ab_ap ///
sa_intv_drug_ai sa_intv_drug_im sa_intv_drug_ki sa_intv_drug_ma sa_intv_drug_mo sa_intv_atmp  {

decode `var', gen(drug`i')
local i=`i'+1
}

gen other = sa_intv_drug_b


gen drug_group = ""

/************************
1, Antiviral not specified | 2, Antiviral broad spectrum | 3, Antiviral antiretrovirals | 4, Other antiviral | 5, Antimalarial | 
6, Antibiotics and antiparasitics | 7, Nonspecific anti-inflammatory and immunosuppressive drugs | 8, Immunosuppressive drugs | 
9, Kinase inhibitors | 10, Monoclonal antibodies | 12, Miscellaneous other | 11, Others | 99, Unknown
************************/

replace drug_group= drug_group + "Antiviral" if sa_intv_drug_av_ns!=.
replace drug_group= drug_group + "Antiviral" if sa_intv_drug_av_bs!=.
replace drug_group= drug_group + "Antiviral" if sa_intv_drug_av_ar!=.
replace drug_group= drug_group + "Antiviral" if sa_intv_drug_av_oth!=.
replace drug_group= drug_group + "Antimalarial" if sa_intv_drug_am!=.
replace drug_group= drug_group + "Antibiotic and other antiparasitic" if sa_intv_drug_ab_ap!=.
replace drug_group= drug_group + "Anti-inflammatory" if sa_intv_drug_ai!=.
replace drug_group= drug_group + "Immunosuppresive drugs" if sa_intv_drug_im!=.
replace drug_group= drug_group + "Kinase inhibitors" if sa_intv_drug_ki!=.
replace drug_group= drug_group + "Monoclonal antibodies" if sa_intv_drug_ma!=.
replace drug_group= drug_group + "Others" if sa_intv_drug_mo!=.

replace drug_group="ATMP" if sa_intv_target==5

gen Drug_w = ""
forval i=1/12 {
replace Drug_w=Drug_w+drug`i'
}



/*
************************************************************************************************************
****get missing drug names
****missing names were extracted and hard coded in external excel file, merged at the beggining of this file
************************************************************************************************************
sort st_reg_id sa_num  intv_num
export excel st_reg_id sa_num arm intv_num sa_intv_desc using "missing drug names_extract.xls" if inlist(Drug, "Unknown","Other" , "")==1, replace
*/



********************RECODING OF CATEGORIES *************************************

sort st_reg_id sa_num intv_num
merge 1:1 st_reg_id sa_num intv_num using dc1
drop if _merge==2

gen Drug = Drug_w
replace Drug=drug_name_correction if inlist(Drug_w, "Unknown","Other" , "")==1

replace Drug="Ribavirin" if st_reg_id=="NCT04276688" & Drug==""


replace Drug="Sofosbuvir" if Drug=="Sofosbovir"
replace Drug="Danoprevir" if Drug=="Ganovo"
replace Drug="PD-1 blocking antibody" if Drug=="PD-1 mAb" 
replace Drug="psychological intervention or drug intervention" if Drug=="Unknown"
replace Drug="Fludase" if Drug=="DAS181"
replace Drug="LL-37 antiviral peptide" if Drug=="CSA0001"

replace Drug= "Dexamethasone" if Drug=="Corticosteroids" & strpos(sa_intv_reg_detail,"Dexamethasone")!=0
replace Drug= "Glucocorticoid" if Drug=="Corticosteroids" & (strpos(sa_intv_desc,"glucocorticoid")!=0 )
replace Drug= "Corticosteroid_ns" if Drug=="Corticosteroids"

replace Drug="Sodium Escinate" if st_reg_id=="NCT04322344" & strpos(sa_intv_reg_detail, "Sodium Escinate")!=0
replace Drug= "Escin" if st_reg_id=="NCT04322344" & strpos(sa_intv_reg_detail, "Escin tablet")!=0
replace Drug="Sodium Escinate" if Drug=="Sodium aescinate"
replace Drug="Enoxaparin Sodium" if Drug=="Prolongin"
replace Drug="Sarilumab" if Drug=="" & strpos(sa_intv_desc,"Sarilumab")!=0 
replace Drug="Anakinra" if Drug=="" & strpos(sa_intv_desc,"Anakinra")!=0

replace Drug="drug intervention" if Drug=="psychological intervention or drug intervention"

replace Drug="Lopinavir" if Drug=="Lopinavir "
replace Drug="Immunoglobulin from cured patients" if Drug=="Immunoglobulin"
replace Drug="Alpha-lipoic acid" if Drug=="" & strpos(sa_intv_desc,"Alpha-lipoic acid")!=0
replace Drug="Alpha-lipoic acid" if Drug=="Lipoic acid" 

***ATMP recoding**************************
replace Drug ="Mesenchymal Stem Cells" if (strpos(Drug,"Mesenchymal stem cells") !=0 | strpos(Drug,"MSCs-Exo") !=0) & drug_group=="ATMP"
replace Drug="Covalescent plasma treatment" if ( strpos(Drug,"Plasma") !=0 | strpos(Drug,"plasma") !=0 ) & drug_group=="ATMP"
replace Drug="Standard Plasma" if inlist(st_reg_id,"NCT04323800")==1 & strpos(sa_intv_desc, "Standard plasma")!=0
replace Drug="Standard Plasma" if inlist(st_reg_id,"ChiCTR2000030929")==1 & strpos(sa_intv_desc, "Ordinary plasma")!=0
replace Drug="Standard Plasma" if inlist(st_reg_id,"ChiCTR2000030010")==1 & strpos(sa_intv_desc, "Ordinary plasma")!=0

replace Drug="Umbilical Cord Mesenchymal Stem Cells" if ( strpos(Drug,"Umbilical cord mesenchymal") !=0 | strpos(Drug,"Umbilical Cord(UC)-derived mesenchymal") !=0 ) & drug_group=="ATMP"
replace Drug="NK Cells" if ( strpos(Drug,"NK Cells") !=0 | strpos(Drug,"NK cells") !=0 ) & drug_group=="ATMP"

 
**********Philippe's suggestion*************************************

replace drug_group="ATMP" if Drug_w=="Immunoglobulin"
replace drug_group="Corticosteroids"  if Drug_w =="Corticosteroids"
replace drug_group="NSAIDs" if Drug_w =="Nonsteroidal anti-inflammatory drug"
replace drug_group="Non-specific anti-inflammatory or immunosuppressive" if Drug=="Sodium Escinate"  | Drug=="Escin"
replace drug_group="Immunosuppressive" if Drug=="Fingolimod"
replace drug_group="Antiviral" if Drug=="Ribavirin"

replace drug_group="Immunosuppressive" if Drug=="Thalidomide"
replace drug_group="Kinase inhibitor" if Drug=="Ruxolitinib"
replace drug_group="Non-specific anti-inflammatory or immunosuppressive" if Drug=="Diammonium glycyrrhizinate"
replace drug_group="Non-specific anti-inflammatory or immunosuppressive" if Drug=="Pirfenidone" | Drug=="Baricitinib" | Drug=="Jacketinib hydrochloride"

replace drug_group="Immunostimulatory" if Drug=="Polyinosinic-polycytidylic acid"
replace drug_group="Immunostimulatory" if Drug=="Thymosin"
replace drug_group="Antioxidant" if Drug=="Vitamin C"
replace drug_group="Antioxidant" if Drug=="Alpha-lipoic acid" 

replace drug_group="Mucolytic agent" if Drug=="Acetylcysteine"      
replace drug_group="Mucolytic agent" if Drug=="Bromhexine hydrochloride"
replace drug_group="Pulmonary arterial hypertension agent" if  Drug=="Sildenafil citrate"
replace drug_group="Sigma receptor modulator" if Drug=="Noscapine"

replace drug_group="Anti-gout"	if Drug=="Colchicine"
replace drug_group="Anticoagulant" if Drug=="Heparin"
replace drug_group="Antifungal"	if Drug=="Itraconazole" | Drug=="prophylactic antifungal therapy"

replace drug_group="Immunostimulatory"	if Drug=="Leukine"
replace drug_group="Antibiotic" if drug_group=="Antibiotic and other antiparasitic" & Drug!="Suramin sodium"
replace drug_group="Non-malarial antiparasitic" if Drug=="Suramin sodium"
replace drug_group="Non-specific anti-inflammatory or immunosuppressive" if drug_group=="Anti-inflammatory"  
replace drug_group="Non-specific anti-inflammatory or immunosuppressive" if Drug=="Anakinra"  

replace drug_group="Protease Inhibitor" if Drug=="Ulinastatin"
replace drug_group="Angiotensin receptor modulator" if Drug=="ACE inhibitor" | Drug=="Losartan"
replace drug_group="Anticoagulant" if Drug=="Enoxaparin Sodium"
replace drug_group="Antiallergic" if Drug=="Tranilast" | Drug=="Ebastine"
replace drug_group="Herbal Syrup" if Drug=="Corostop" | Drug=="Coroguard"


replace drug_group="Unable to classify" if drug_group=="" | drug_group=="Others"

replace drug_group="Exclude" if Drug=="High flow therapy by nasal cannulae" | Drug== "Bag-valve mask oxygenation" | Drug=="Inhaled gases" | Drug=="Dexmedetomidine"


**********Novaferon tablets and spray treated as two interventions in the same arm -  traete it as one intervention with Novaferon************
replace drug_group="Exclude" if Drug=="Novaferon" & st_reg_id=="ChiCTR2000030000" & sa_num==3 & intv_num==2

******************************************************************
***********number with arms**************************************
egen arm1 = group(st_reg_id sa_num) if drug_group=="Antiviral"
su arm1
drop arm1
egen arm1 = group(st_reg_id sa_num) if drug_group=="Antimalarial"
su arm1
drop arm1
egen arm1 = group(st_reg_id sa_num) if drug_group=="ATMP"
su arm1
drop arm1
egen arm1 = group(st_reg_id sa_num) if drug_group=="Monoclonal antibodies"
su arm1
drop arm1

egen arm1 = group(st_reg_id sa_num) if sa_num_planned<.
su arm1
drop arm1

sort st_reg_id sa_num
by st_reg_id sa_num: gen first=1 if _n==1
tabstat sa_num_planned if first==1, s(n med min max p25 p75)
drop first

egen arm1 = group(st_reg_id sa_num) if sa_num_planned<. & study_type=="RCT"
su arm1
drop arm1

egen arm1 = group(st_reg_id sa_num) if sa_num_planned<. & study_type=="Cohort / non-norandomised"
su arm1
drop arm1

egen ninterv=group(Drug)
egen ndr_cat = group(drug_group)
egen ninterv1=group(Drug) if study_type=="RCT"
su ninterv ndr_cat ninterv1

egen na1= group(st_reg_id sa_num) if st_prevention==1
egen na0= group(st_reg_id sa_num) if st_prevention==0

egen ns1= group(st_reg_id ) if st_prevention==1
egen ns0= group(st_reg_id ) if st_prevention==0

su na1 na0 ns1 ns0

drop ninterv ndr_cat ninterv1 na1 na0 ns1 ns0
******************************************************************************
******************************************************************************
save "all drug data for paper_7MAY2020.dta", replace


drop if drug_group=="Exclude"
 
keep study st_reg_id sa_num arm intv_num sa_num_intv sa_intv_desc sa_intv_reg_detail sa_comb Drug other drug_group st_prevention study_type sa_intv_target sa_intv_med_type st_design st_diag_design sa_num_planned 

save "drug data for paper_7MAY2020.dta", replace

***********checks***********************
/*
sort drug_group Drug
by drug_group Drug: gen dfirst=1 if _n==1

sort st_reg_id
export excel st_reg_id sa_intv_desc drug_group Drug sa_intv_med_type  using "missing and other drug category to check.xls" if Drug=="" | inlist(sa_intv_med_type, 11,12,99,.)==1, replace first(var)

sort sa_intv_med_type Drug
export excel  sa_intv_med_type Drug using "drug categories to check.xls" if Drug!="" & dfirst==1, replace first(var)
*/

*********************************************************************************************************************
use  "drug data for paper_7MAY2020.dta", clear

************************************************************************************
gen use=1
gen line=_n

gen stype=""
gen dgroup=""
gen ndrug=""
gen Narm_total=.
gen Narm_ss=.
gen Narm_comb=.
gen Narm_alone=.
gen Npat_total=.
gen Nstudy=.
gen e_med=.
gen e_25=.
gen e_75=.
gen e_min=.
gen e_max=.


egen ndrugs = total(use), by(study arm)

egen study_type_n=group(study_type)
su study_type_n
local ns = r(max) 
egen drug_group_n=group(drug_group)
su drug_group_n 
local nd=r(max)



local k=1
forval i=1/`ns' {

***by study type******************

tabstat study_type_n  if study_type_n==`i', by(study_type) save
replace stype= r(name1) if line==`k'
replace dgroup = "ALL" if line==`k'
replace ndrug="ALL" if line==`k'

egen x = group(study) if study_type_n==`i'
su x
replace Nstudy = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i'
su x
replace Narm_total = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i' & sa_num_planned<.
su x
replace Narm_ss = r(max) if line==`k'
drop x


sort study_type_n study arm intv_num
by study_type_n study arm: gen y =_n


egen x= total(sa_num_planned) if study_type_n==`i' & y==1
su x
replace Npat_total = r(max) if line==`k'


tabstat sa_num_planned if study_type_n==`i'  & y==1, s(med p25 p75 min max) save
matrix A =  r(StatTotal)
replace e_med= A[1,1] if line==`k' 
replace e_25 = A[2,1]  if line==`k'
replace e_75= A[3,1] if line==`k'
replace e_min=A[4,1] if line==`k'
replace e_max=A[5,1] if line==`k'


drop x y

local k=`k'+1



forval j=1/`nd' {

**********by drug group*****************

egen x = group(study) if study_type_n==`i' & drug_group_n==`j'
su x
replace Nstudy = r(max) if line==`k'
drop x


egen x = group(study arm) if study_type_n==`i' & drug_group_n==`j'
su x

replace Narm_total = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i' & sa_num_planned<. & drug_group_n==`j'
su x
replace Narm_ss = r(max) if line==`k'
drop x

sort study_type_n drug_group_n study arm intv_num
by study_type_n drug_group_n study arm: gen y =_n

egen x= total(sa_num_planned) if study_type_n==`i'  & drug_group_n==`j' & y==1
su x
replace Npat_total = r(max) if line==`k'

capture: tabstat sa_num_planned if study_type_n==`i' & drug_group_n==`j' & y==1, s(med p25 p75 min max) save
matrix A =  r(StatTotal)
replace e_med= A[1,1] if line==`k' 
replace e_25 = A[2,1]  if line==`k'
replace e_75= A[3,1] if line==`k'
replace e_min=A[4,1] if line==`k'
replace e_max=A[5,1] if line==`k'

drop x y

egen x = group(study arm) if study_type_n==`i'  & drug_group_n==`j' & ndrugs==1
su x
replace Narm_alone = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i'  & drug_group_n==`j' & ndrugs>1 &  ndrugs<.
su x
replace Narm_comb = r(max) if line==`k'
drop x

tabstat drug_group_n  if drug_group_n==`j', by(drug_group) save
replace dgroup= r(name1) if line==`k'
tabstat study_type_n  if study_type_n==`i', by(study_type) save
replace stype= r(name1) if line==`k'
replace ndrug="ALL" if line==`k'
local k=`k'+1  


egen drug_name_n = group(Drug) if study_type_n==`i' &  drug_group_n==`j'
su drug_name_n
local na=r(max)

if (`na' !=. & `na'!=0 ) {
forval l=1/`na' {


**********by drug*****************

egen x = group(study) if study_type_n==`i' & drug_name_n==`l'  & drug_group_n==`j'
su x
replace Nstudy = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i' & drug_name_n==`l'  & drug_group_n==`j'
su x

replace Narm_total = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i' & sa_num_planned<. & drug_name_n==`l' & drug_group_n==`j'
su x
replace Narm_ss = r(max) if line==`k'
drop x

sort study_type_n drug_group_n drug_name_n study arm intv_num
by study_type_n drug_group_n drug_name_n study arm: gen y =_n

egen x= total(sa_num_planned) if study_type_n==`i' & drug_name_n==`l'  & drug_group_n==`j' & y==1
su x
replace Npat_total = r(max) if line==`k'


tabstat sa_num_planned if study_type_n==`i' & drug_name_n==`l'  & drug_group_n==`j' & y==1, s(med p25 p75 min max) save
matrix A =  r(StatTotal)
replace e_med= A[1,1] if line==`k' 
replace e_25 = A[2,1]  if line==`k'
replace e_75= A[3,1] if line==`k'
replace e_min=A[4,1] if line==`k'
replace e_max=A[5,1] if line==`k'

drop x y


egen x = group(study arm) if study_type_n==`i' & ndrugs==1 & drug_name_n==`l' & drug_group_n==`j'
su x
replace Narm_alone = r(max) if line==`k'
drop x

egen x = group(study arm) if study_type_n==`i'  & ndrugs>1 &  ndrugs<. & drug_name_n==`l' &  drug_group_n==`j'
su x
replace Narm_comb = r(max) if line==`k'
drop x


capture: tabstat drug_group_n  if drug_group_n==`j', by(drug_group) save
replace dgroup= r(name1) if line==`k'

capture: tabstat study_type_n  if study_type_n==`i', by(study_type) save
replace stype= r(name1) if line==`k'

capture: tabstat drug_name_n  if drug_name_n==`l', by(Drug) save
replace ndrug= r(name1) if line==`k'

local k=`k'+1  
}
}
drop drug_name_n
}
}


gen Dgroup=dgroup
replace Dgroup="" if ndrug!="ALL"

gen Ndrug=ndrug
replace Ndrug="" if ndrug=="ALL"

gen DGname=Ndrug
replace DGname=Dgroup if DGname==""

gen nyes=1 if Ndrug!=""
gen linex = line 
sort line
replace linex=linex[_n-1] if  nyes==1 & nyes[_n-1]==1


gen e_iqr = string(e_25) + " - " + string(e_75)
gen e_range= string(e_min) + " - " + string(e_max)


gsort linex -Narm_total
brow stype Dgroup Ndrug DGname Nstudy Narm_total Narm_ss Npat_total e_med e_iqr e_range Narm_comb Narm_alone if stype!="" & (Narm_total<.) & Ndrug!="Unknown"

export excel  stype Dgroup Ndrug DGname Nstudy Narm_total Narm_ss Npat_total e_med e_iqr e_range Narm_comb Narm_alone using "Drug_Table1_7MAY2020.xls" if stype!="" & (Narm_total<.) & Ndrug!="Unknown", replace first(var)


*********************************************************************************
**********************************************************************************

keep study st_reg_id sa_num intv_num arm sa_intv_desc sa_intv_reg_detail st_prevention  Drug other drug_group study_type  sa_intv_med_type sa_num_planned sa_comb 
save "drug combination data for paper_7MAY2020.dta", replace
**************************************************************************************************************

use "drug combination data for paper_7MAY2020.dta", clear

/**********nOT combinations**************************
NCT04286503 sa_num==2  L/R or Chlo or Abridol
*NCT04275388 sa_num==1  L+alpha_interfefom nebulation or Rotinavir + alfa_interferon nebulasation
*NCT04275388 sa_num==2  Xiyanping + Lopinavir or Rotinavir + alfa_interferon nebulasation
ISRCTN83971151	sa_num=3 choloro or hydroxy
*/


egen unit=group(study arm)
sort unit drug_group Drug
by unit: gen record = _n


reshape wide Drug drug_group sa_intv* intv_num other , i(unit) j(record)


gen drug_group_comb = drug_group1 + cond(drug_group2=="","","/"+drug_group2) + cond(drug_group3=="","","/"+drug_group3) + cond(drug_group4=="","","/"+drug_group4)
gen drug_comb = Drug1 + cond(Drug2=="","","/"+Drug2) + cond(Drug3=="","","/"+Drug3) + cond(Drug4=="","","/"+Drug4)

gen comb=1 if strpos(drug_group_comb,"/")!=0



gen drug_group_comb2 = drug_group1 + cond(drug_group2=="","",cond(drug_group1==drug_group2,"2","/"+drug_group2)) ///
 + cond(drug_group3=="","",cond(drug_group3==drug_group2,"2","/"+drug_group3)) + cond(drug_group4=="","",cond(drug_group4==drug_group3,"2","/"+drug_group4))



gen comb_cat ="Antivirals" if drug_group_comb2=="Antiviral2"
replace comb_cat ="Antivirals" if drug_group_comb2=="Antiviral222"
replace comb_cat ="Antivirals" if drug_group_comb2=="Antiviral22"

replace comb_cat = "Antiviral/"+subinstr(drug_group_comb2,"Antiviral","",1) if comb_cat=="" & strpos(drug_group_comb2,"Antiviral")!=0 & comb==1

replace comb_cat ="Antimalarials" if drug_group_comb2=="Antimalarial2"
replace comb_cat = "Antimalarial/"+subinstr(drug_group_comb2,"Antimalarial","",1) if comb_cat=="" & strpos(drug_group_comb2,"Antimalarial")!=0 & comb==1

replace comb_cat ="ATMPs" if drug_group_comb2=="ATMP2"
replace comb_cat = "ATMP/"+subinstr(drug_group_comb2,"ATMP","",1) if comb_cat=="" & strpos(drug_group_comb2,"ATMP")!=0 & comb==1

replace comb_cat ="Monoclonal antibodies" if drug_group_comb2=="Monoclonal antibodies2"
replace comb_cat = "Monoclonal antibodies/"+subinstr(drug_group_comb2,"Monoclonal antibodies","",1) if comb_cat=="" & strpos(drug_group_comb2,"Monoclonal antibodies")!=0 & comb==1

replace comb_cat= drug_group_comb2 if comb_cat==""


tab comb_cat if comb==1

************corrections due to sa_comb==3***************************************
brow comb st_reg_id drug_comb drug_group_comb2 sa_num if inlist(st_reg_id,"NCT04275388", "NCT04286503", "NCT04275388", "ISRCTN83971151")==1

replace comb=. if st_reg_id=="ISRCTN83971151" & sa_num==3
replace drug_comb="Lopinavir/Ritonavir" if st_reg_id=="NCT04286503" & sa_num==2
replace comb_cat="Antivirals" if st_reg_id=="NCT04286503" & sa_num==2




********************************************************************************
gen drug_comb1=drug_comb
replace drug_comb1 = subinstr(drug_comb1, "Ritonavir/Lopinavir", "Lopinavir/Ritonavir", 1)
replace drug_comb1 = subinstr(drug_comb1, "Ritonavir/Danoprevir", "Danoprevir/Ritonavir", 1)

gen comb_cat1 = subinstr(comb_cat,"2","",5) if comb==1
replace comb_cat1 = subinstr(comb_cat1,"//","/",1) if comb==1

gen corder=.
replace corder=	13	if comb_cat1=="ATMP/Kinase inhibitor"
replace corder=	12	if comb_cat1=="ATMPs"
replace corder=	11	if comb_cat1=="Antimalarial/Antibiotic/"
replace corder=	10	if comb_cat1=="Antimalarials"
replace corder=	17	if comb_cat1=="Antioxidant/Non-specific anti-inflammatory or immunosuppressive"
replace corder=	5	if comb_cat1=="Antiviral/Antiallergic/"
replace corder=	2	if comb_cat1=="Antiviral/Antimalarial/"
replace corder=	6	if comb_cat1=="Antiviral/Corticosteroids"
replace corder=	9	if comb_cat1=="Antiviral/Corticosteroids/Immunosuppressive"
replace corder=	3	if comb_cat1=="Antiviral/Immunostimulatory"
replace corder=	4	if comb_cat1=="Antiviral/Monoclonal antibodies"
replace corder=	7	if comb_cat1=="Antiviral/Mucolytic agent"
replace corder=	8	if comb_cat1=="Antiviral/Non-specific anti-inflammatory or immunosuppressive"
replace corder=	1	if comb_cat1=="Antivirals"
replace corder=	18	if comb_cat1=="Corticosteroids"
replace corder=	19	if comb_cat1=="Herbal Syrup"
replace corder=	14	if comb_cat1=="Monoclonal antibodies"
replace corder=	15	if comb_cat1=="Monoclonal antibodies/Antibiotic/"
replace corder=	16	if comb_cat1=="Monoclonal antibodies/Corticosteroids/"


gen comb_cat2=comb_cat1



***********by study type****************
***number of arms
egen dr_comb_n1 = total(comb) if comb==1, by(comb study_type comb_cat2 drug_comb1) 
egen comb_cat_n1 = total(comb) if comb==1, by(comb study_type comb_cat2) 

egen Narm1 = total(comb) if comb==1 & sa_num_planned<., by(comb study_type comb_cat2 drug_comb1)
egen Narm2 = max(Narm1) if comb==1, by(comb study_type comb_cat2 drug_comb1)
egen Ntot = total(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1)
egen Nmed=median(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1)
egen N25=pctile(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1) p(25)
egen N75=pctile(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1) p(75)
egen Nmin=min(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1)
egen Nmax=max(sa_num_planned) if comb==1, by(comb study_type comb_cat2 drug_comb1)


***number of studies
sort comb study_type comb_cat2 study
by comb study_type comb_cat2 study: gen fstudy1a=1 if _n==1 & comb==1

****per combination type*****
egen Nstudy1a = total(fstudy1a) if comb==1, by(comb study_type comb_cat2)

****per drug combination****
sort comb study_type comb_cat2 drug_comb1 study
by comb study_type comb_cat2 drug_comb1 study: gen fstudy2a=1 if _n==1 & comb==1

egen Nstudy2a = total(fstudy2a) if comb==1, by(comb study_type drug_comb1 comb_cat2)


gen Nrange = string(Nmin) + " - " + string(Nmax)
gen Niqr = string(N25) + " - " + string(N75)

sort comb study_type comb_cat2 drug_comb1
by comb study_type comb_cat2 drug_comb1: gen cfirst1=1 if _n==1 & comb==1


gen drug_comb2=drug_comb1



replace drug_comb1 ="Chloroquine/Azithromycin" if drug_comb2=="Azithromycin/Chloroquine" 
replace drug_comb1 ="Hydroxychloroquine/Azithromycin" if drug_comb2=="Azithromycin/Hydroxychloroquine"
replace drug_comb1 ="Interferons/Lopinavir/Ebastine" if drug_comb2=="Ebastine/Lopinavir/Interferons"

replace drug_comb1 = subinstr(drug_comb1,"Chloroquine/","",1)+ "/Chloroquine" if comb_cat2 == "Antiviral/Antimalarial/" & strpos(drug_comb1,"Chloroquine")!=0 & comb==1
replace drug_comb1 = subinstr(drug_comb1,"Hydroxychloroquine/","",1)+ "/Hydroxychloroquine" if comb_cat2 == "Antiviral/Antimalarial/" & strpos(drug_comb1,"Hydroxychloroquine")!=0 & comb==1

replace drug_comb1 = subinstr(drug_comb1,"Umifenovir/Interferons","Interferons/Umifenovir",1) 
replace drug_comb1 = "Eculizumab/Ceftraxone" if drug_comb1=="Ceftraxone/Eculizumab" 
replace drug_comb1 = "Mepolizumap/Corticosteroid_not specified" if  drug_comb1=="Corticosteroid_ns/Mepolizumab"


****************summary numbers*************************************************
egen ncomb= group(drug_comb1) if comb==1 
su ncomb
drop ncomb
egen ncomb= group(drug_comb1) if comb==1 & study_type=="RCT"
egen narms=group(st_reg_id sa_num) if comb==1 & study_type=="RCT"
egen nstudies=group(st_reg_id) if comb==1 & study_type=="RCT"
su nstudies narms ncomb
drop nstudies narms ncomb
tab drug_comb1 if comb==1 & study_type=="RCT"


egen na1= group(st_reg_id sa_num) if st_prevention==1 & comb==1
egen na0= group(st_reg_id sa_num) if st_prevention==0 & comb==1

egen ns1= group(st_reg_id ) if st_prevention==1 & comb==1
egen ns0= group(st_reg_id ) if st_prevention==0 & comb==1

su na1 na0 ns1 ns0

*********************************************************************************

brow  study_type comb_cat2 drug_comb1 dr_comb_n1 comb_cat_n1 Nstudy1a Nstudy2a Narm2 Ntot Nmed Niqr Nrange if cfirst1==1 & comb==1
gsort comb study_type corder -dr_comb_n drug_comb1
export excel study_type comb_cat2 drug_comb1 dr_comb_n1 comb_cat_n1 Nstudy1a Nstudy2a Narm2 Ntot Nmed Niqr Nrange using "Drug_Table2_7MAY2020.xls" if cfirst1==1 & comb==1, replace first(var)

 
 

 
 
 
 